import http from '@/util/request.js'

export default {
    // 根据id获取秒杀商品信息
    getSeckillGoodsById: (id) => {
        return http({
            url: `/api/seckill/goods/id/${id}`,
            method: 'get'
        })
    },

    // 根据商品id获取秒杀商品信息
    getSeckillGoodsByGoodsId: (goodsId) => {
        return http({
            url: `/api/seckill/goods/goodsid/${goodsId}`,
            method: 'get'
        })
    },

    // 添加秒杀商品
    addSeckillGoods: (data) => {
        return http({
            url: '/api/seckill/goods/add',
            method: 'post',
            data
        })
    },

    // 更新秒杀商品
    updateSeckillGoods: (data) => {
        return http({
            url: '/api/seckill/goods/update',
            method: 'put',
            data
        })
    },

    // 删除秒杀商品(软删除)
    deleteSeckillGoods: (id) => {
        return http({
            url: `/api/seckill/goods/delete/${id}`,
            method: 'delete'
        })
    },

    // 切换秒杀商品状态
    reverseStatus: (id) => {
        return http({
            url: `/api/seckill/goods/status/${id}`,
            method: 'put'
        })
    },

    // 获取秒杀商品列表
    getSeckillGoodsList: (data) => {
        return http({
            url: '/api/seckill/goods/list',
            method: 'get',
            params: data
        })
    },

    // 获取秒杀商品分页列表
    getSeckillGoodsPage: (current, size, data) => {
        return http({
            url: '/api/seckill/goods/page',
            method: 'get',
            params: {
                current: current,
                size: size,
                ...data
            }
        })
    }
}
